/**
 * 
 */
package net.homelinux.ajay.net.ondisk.view.client;


import net.homelinux.ajay.net.ondisk.model.client.AppObject;
import net.homelinux.ajay.net.ondisk.model.client.ModelChangeListener;
import net.homelinux.ajay.net.ondisk.model.client.MetaFactory;

import com.google.gwt.user.client.ui.Widget;

/**
 * @author ajay
 *
 */
public class LinkTreeItem extends AppTreeItem implements ModelChangeListener {

  /**
   * 
   */
  public LinkTreeItem() {
  }

  /**
   * @param html
   */
  public LinkTreeItem(String html) {
    super(html, null);
  }

//  /**
//   * @param widget
//   */
//  public URLTreeItem(Widget widget) {
//    super(widget);
//  }

  /* (non-Javadoc)
   * @see net.homelinux.ajay.net.ondisk.client.TreeItem#makeChild(java.lang.String)
   */
  public AppTreeItem makeChild(String text) {
    throw new RuntimeException("NO IMPLEMENT");
  }

  public static LinkTreeItem makeChild(String text, FolderTreeItem item) {
    AppObject meta = MetaFactory.getInstance().getMeta(text);
    LinkTreeItem itm = new LinkTreeItem(HTMLUtils.toHtml(meta));
    itm.setUserObject(meta);
    item.addItem(itm);
    meta.addModelChangeListener(itm);
    
    return itm;
  }

  public void onDeselect() {
    // NOOP
    
  }

  public void onSelect() {
    // NOOP
    
  }

  public void onModelChange(AppObject meta) {
    setHTML(HTMLUtils.toHtml(meta));
  }

  protected CommandsMenu getCommandsMenu() {
    // TODO Implement commands menu for link
    return null;
  }

}
